package edu.dayu.controller;

import edu.dayu.pojo.ActivityType;
import edu.dayu.pojo.ArticleType;
import edu.dayu.service.ActivityTypeService;
import edu.dayu.service.ArticleTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@CrossOrigin
@RequestMapping("/admin")
public class ActivityTypeController {
    @Autowired
    private ActivityTypeService activityTypeService;

    @PostMapping("/activityTypeList")
    public List<ActivityType> activityTypeList (ActivityType articleType){
        return  activityTypeService.activityTypeList(articleType);
    }

    @PostMapping("/activityTypeInsert")
    public void activityTypeInsert(ActivityType articleType){
        activityTypeService.activityTypeInsert(articleType);
    }

    @PostMapping("/activityTypeUpdate")
    public void activityTypeUpdate(ActivityType articleType){
        activityTypeService.activityTypeUpdate(articleType);
    }

    @PostMapping("/activityTypeById")
    public ActivityType activityTypeById(ActivityType activityType){
        List<ActivityType> activityTypes = activityTypeService.activityTypeList(activityType);
        ActivityType activityType1 = new ActivityType();
        for (ActivityType type : activityTypes) {
            activityType1 = type;
        }
        return activityType1;
    }

    @PostMapping("/activityTypeDelete")
    public void activityTypeDelete(ActivityType activityType){
        activityTypeService.activityTypeDelete(activityType);
    }
}
